<template>
  <div class="app-container">
    <el-tabs
      v-model="activeTab"
      style="
        position: absolute;
        width: 100%;
        height: 553px;
        top: 0%;
        left: 0.159744%;
        text-align: left;
      "
      :tab-position="tabPosition"
      stretch
    >
      <el-tab-pane name="first" style="height: 474px" label="论文查看">
        <Essay/>
      </el-tab-pane>
      <el-tab-pane
        name="second"
        style="height: 474px"
        label="著作查看"
      >
        <Book/>
      </el-tab-pane>
      <el-tab-pane
        name="three"
        style="height: 475px"
        label="著作权查看"
      >
        <Copyright/>
      </el-tab-pane>
      <el-tab-pane
        name="four"
        style="height: 473px"
        label="结题/验收查看"
      >
        <Project/>
      </el-tab-pane>
      <el-tab-pane
        name="five"
        style="height: 472px"
        label="获奖查看"
      >
        <Award/>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import {
  delPerson,
  addPerson,
  updatePerson,exportSelf,
} from "@/api/teacher/person";
import FileUpload from "@/components/FileUpload";
import Essay from "@/views/teacher/essay";
import Book from "@/views/teacher/book";
import Copyright from "@/views/teacher/copyright";
import Project from "@/views/teacher/project";
import Award from "@/views/teacher/award";

export default {
  name: "Person",
  components: {
    Essay,
    FileUpload,
    Book,
    Copyright,
    Project,
    Award
  },
  data() {
    return {
      hidden: false,
      activeTab: "first",
      tabPosition: "top",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 教师基本信息表格数据
      personList: [],
      //教育信息
      educationList: [],
      //工作经历
      workInfoList: [],
      //职称信息
      personTitleList: [],
      //培训情况
      trainInfoList: [],
      //考核信息
      assessmentList: [],
      //档案信息
      personFileList: [],
      //附件材料
      appendixList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        // userId: 115,
        a0101: null,
        a0104: null,
        a0141: null,
        a0199: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        a00: [
          { required: true, message: "人员标识符不能为空", trigger: "blur" },
        ],
        a0101: [{ required: true, message: "姓名不能为空", trigger: "blur" }],
      },
    };
  },
  created() {
  },
  methods: {
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 撤销按钮
    revoke() {
      this.hidden = false;
      this.getTeacherInfo();
    },
    // 表单重置
    reset() {
      this.hidden = false;
      this.form = {
        a00: null,
        a0101: null,
        userId: null,
        a0104: null,
        a0107: null,
        a0111b: null,
        a0114b: null,
        a0117: null,
        a0127: null,
        a0131: null,
        a0134: null,
        a0141: null,
        a0181a: null,
        a0183: null,
        a0184: null,
        a0199: null,
        zdyxa0106: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: null,
        remark: null,
        zdyxa0109: null,
        zdyxa01110: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getTeacherInfo();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      // this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.a00);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 保存按钮操作 */
    handleSave () {
      localStorage.setItem("form",JSON.stringify(this.form));
      this.hidden = false;
    },
    /** 修改按钮操作 */
    // handleRevoke() {
    //   this.xiugaibasic = false;
    // },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.hidden = true;
      // const a00 = row.a00;
      // getTeacherInfo(a00).then((response) => {
      //   this.form = response.data;
      //   this.title = "修改教师基本信息";
      // });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.a00 != null) {
            updatePerson(this.form).then((response) => {
              this.loading = true;
              this.msgSuccess("修改成功");
              this.hidden = false;
              this.open = false;
              this.getTeacherInfo();
            });
          } else {
            addPerson(this.form).then((response) => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getTeacherInfo();
            });
          }
        }
      });
      // setTimeout(() => {
      //   this.revoke();
      // }, 3000);
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const a00s = row.a00 || this.ids;
      this.$confirm(
        '是否确认删除教师基本信息编号为"' + a00s + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delPerson(a00s);
        })
        .then(() => {
          this.getTeacherInfo();
          this.msgSuccess("删除成功");
        });
    },
    /** 导出按钮操作 */
    handleExport() {
      let A00 = this.A00;
      this.$confirm("是否确认导出所有教师基本信息数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportSelf(A00);
        })
        .then((response) => {
          this.download(response.msg);
        });
    },
  },
};
</script>
<style>
::v-deep .el-tabs__nav-scroll {
  width: 50% !important;
  margin: 0 auto !important;
}
.el-form--inline .el-form-item {
  width: 31%;
  float: left;
}
.el-form-item--medium .el-form-item__content {
  margin-left: 30px !important;
}
.el-form-item {
  margin-bottom: 45px;
}
</style>
